#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>

using namespace std;

int cnt = 0;

void Hanoi(string A, string B, string C, int n, int m)
{
	if (n == 1)
	{
		cnt++;
		if (cnt == m)
		{
			cout << "#" << n << ": " << A << "->" << C << endl;
		}
	}
	else
	{
		Hanoi(A, C, B, n - 1, m);
		cnt++;
		if (cnt == m)
		{
			cout << "#" << n << ": " << A << "->" << C << endl;
		}
		Hanoi(B, A, C, n - 1, m);
	}
}

int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	Hanoi("A", "B", "C", n, m);
	cout << cnt << endl;
	return 0;
}
